﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using imaginecup.information;
using imaginecup.objectManager;
using Imaginecup.observer;

namespace Imaginecup.gameState.malaria.component
{
    public class BaseSubjectEntity:BaseEntityComponent , ISubject
    {
        private List<IObserver> m_ObserverList;

        public BaseSubjectEntity(GObjectID a_GID, ObjectManager objMan , SComponentTypeID typeID )
            : base(a_GID, objMan, typeID )
        {
            m_ObserverList = new List<IObserver>();
        }

        public void AddObserver(IObserver observer)
        {
            m_ObserverList.Add(observer);
        }

        protected void NotifyAll(Object Data)
        {
            foreach( IObserver observer in m_ObserverList )
            {
                observer.Notify(Data);
            }

        }

        public override void Release()
        {
            m_ObserverList.Clear();
            m_ObserverList = null;
            base.Release();
        }
    }
}
